from settings import *


class BaseGroup(PG.sprite.Group):
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.sprite_mapping = {}

    def add_internal(self, sprite, layer=None):
        if getattr(sprite, "gen_id", None):
            sprite.oid = f"{sprite.__class__.__name__}-{next(sprite.gen_id)}"
            super().add_internal(sprite, layer=layer)
            self.sprite_mapping[sprite.oid] = sprite
        else:
            super().add_internal(sprite, layer=layer)
